package cn.bigfire.compiler.dragon.appendixA.handwrite.inter;

import cn.bigfire.compiler.dragon.appendixA.handwrite.symbols.Type;

public class Do extends Stmt {

    Expr expr;
    Stmt stmt;


    public Do(){

    }

    public void init(Stmt stmt, Expr expr) {
        this.expr = expr;
        this.stmt = stmt;
        if (expr.type != Type.Bool) {
            expr.error("boolean required in do");
        }
    }

    public void gen(int b, int a) {
        after = a;
        int label = newLabel();
        stmt.gen(b, label);
        emitLabel(label);
        expr.jumping(b, 0);

    }

}
